﻿/**************************************************************
 * Copyright Eastmoney Corporation. All rights reserved.
 * 
 * Author: guitao(guitao@eastmoney.com) 
 * Create Date: 2019/11/6 9:37:33
 * Description:
 *          
 * Revision History:
 *      Date         Author               Description
 *              
***************************************************************/

using gt.dotnetcore.consolesample.Biz;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using Quartz;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace gt.dotnetcore.consolesample.Job
{
    public class Test2Job : IJob
    {
        private ITest _testService;
        private AppSetting _appsetting;
        private IConfiguration _configuration;

        public Test2Job(ITest testService, IOptionsMonitor<AppSetting> appSettingAccessor, IConfiguration configuration)
        {
            _testService = testService;
            _appsetting = appSettingAccessor.CurrentValue;
            _configuration = configuration;
        }
        public Task Execute(IJobExecutionContext context)
        {
            Console.WriteLine($"job2222222222222 started:{_appsetting.TestCN}");
            var t = _testService.Dowork(1);
            t.Wait();
            Console.WriteLine($"job2222222222222 ended:{_configuration["TestCN"]}");

            return Task.CompletedTask;
        }
    }
}
